import request from '@/plugins/sourcing-request'
import { ApiRequestExportTable } from '@api/basePage';
import { sourcingRequest } from '@api/service/sourcing'
const URL_PREFIX = '/inquiry';
const URL_ORDERPREFIX = '/orderGoodsEntry'
// 首页待办事项
export const eventRemindService = (data) => {
  return request({
    url: `/eventRemind`,
    method: 'GET',
    data
  })
}
// 询价需求---列表查询
export const getDemandInqeryListService = (data, loadingFn) => sourcingRequest({
  url: `${URL_PREFIX}/query-inquiry-page`,
  type: 'POST',
  data,
  loadingFn,
})

// 导出客户询价需求
export const exportDemandInquiryService = (data, loadingFn) => sourcingRequest({
  url: `${URL_PREFIX}/export-inquiry-xls`,
  type: 'post',
  data,
  loadingFn,
  isExport: true
})

// 订货需求 ---列表查询
export const getOrderListService = (data, loadingFn) => sourcingRequest({
  url: 'orderGoodsEntry/selectPage',
  type: 'POST',
  data,
  loadingFn,
})
// 询价需求---转派人员保存
export const requirementSwithService = (data) => {
  return request({
    url: `${URL_PREFIX}/requirement-switch`,
    method: 'POST',
    data
  })
}
// 订货需求---转派人员保存
export const transferOrderGoodsService = (data) => {
  return request({
    url: `${URL_ORDERPREFIX}/transferOrderGoods`,
    method: 'POST',
    data
  })
}
// 询价需求---转派记录
export const getTransferRecordService = (data, loadingFn) => sourcingRequest({
  url: 'switch-log/switch-dept-page',
  type: 'POST',
  data,
  loadingFn,
})
// 询价需求---询价异常记录
export const getAbnormalRecordService = (data, loadingFn) => sourcingRequest({
  url: 'expLog/selectPage',
  type: 'POST',
  data,
  loadingFn,
})
// 询价需求---询价异常接口 保存
export const expInquiryService = (data) => {
  return request({
    url: `${URL_PREFIX}/exp-inquiry`,
    method: 'POST',
    data
  })
}
// 订货需求---询价异常接口 保存
export const exceptionOrderGoodsService = (data) => {
  return request({
    url: `${URL_ORDERPREFIX}/exceptionOrderGoods`,
    method: 'POST',
    data
  })
}
// 询价需求--- 询受理
export const srmAcceptService = (data) => {
  return request({
    url: `${URL_PREFIX}/srm-accept`,
    method: 'POST',
    data
  })
}
// 订货需求---受理
export const acceptanceService = (data) => {
  return request({
    url: `${URL_ORDERPREFIX}/acceptance`,
    method: 'POST',
    data
  })
}
// 询价需求--- 取消受理
export const srmCancelAcceptService = (data) => {
  return request({
    url: `${URL_PREFIX}/srm-cancel-accept`,
    method: 'POST',
    data
  })
}
// 订货需求--- 取消受理
export const cancelAcceptanceService = (data) => {
  return request({
    url: `${URL_ORDERPREFIX}/cancelAcceptance`,
    method: 'POST',
    data
  })
}

// 询价需求 询价 ---采购询价 生成询价单据
export const sourceGenBillService = (data) => {
  return request({
    url: `/sourceBill/genBill`,
    method: 'POST',
    data
  })
}
// 询价需求 订货 ---采购询价 生成询价单据
export const handleOrderInquiryService = (data) => {
  return request({
    url: `/orderInquiry/handleOrderInquiry`,
    method: 'POST',
    data
  })
}
// 采购询价 ---- 客户订货 -- 询价异常取消
export const cancelOrderService = (data) => {
  return request({
    url: `/orderInquiry/cancelOrder`,
    method: 'POST',
    data
  })
}
// 采购询价 ---- 客户询价 -- 询价异常取消
export const cancelInquiryService = (data) => {
  return request({
    url: `/sourceBill/cancelInquiry`,
    method: 'POST',
    data
  })
}
// 询价需求 ---询价 订货 --- 人员转派 ---部门
export const queryHrDeptService = (data) => {
  return request({
    url: `/hr/queryHrDept`,
    method: 'GET',
    data
  })
}
// 询价需求 ---询价 订货 --- 人员转派 ---人员
export const queryHrUserService = (data) => {
  return request({
    url: `/hr/queryHrUser`,
    method: 'GET',
    data
  })
}
// 导出客户订货需求
export const exportDemandOrderService = (data, loadingFn) => sourcingRequest({
  url: 'orderGoodsEntry/exportFile',
  type: 'post',
  data,
  loadingFn,
  isExport: true
})

// 获取四级类一级分类
export const queryCategoryService = (data) => {
  return request({
    // url: '/sourceBill/getProductCategory',
    url: '/product/getCategory',
    method: 'get',
    data: {}
  })
}
// 获取四级类子级分类
export const queryChildCategoryService = (data) => {
  return request({
    url: `/product/getCategory/${data}`,
    method: 'get',
    data: {}
  })
}

// 获取关联商品需求列表
export const queryInquirySkuService = (data, loadingFn) => sourcingRequest({
  url: 'product/checkInquiryAndQuery',
  type: 'POST',
  data,
  loadingFn,
})

// 获取正常商品列表
export const querySkuService = (data) => {
  return request({
    url: '/product/getNormalSkuByParam',
    method: 'post',
    data
  })
}
// 关联正常商品提交
export const associatedGoodsSubmitService = (data) => {
  return request({
    url: '/product/commitInquiryNormalRel',
    method: 'post',
    data
  })
}

// 导出询价需求
export const exportDemandService = (data) => {
  return ApiRequestExportTable(`/srm-api/product/exportTemplate`, 'POST', data)
}

// 修改商品为主码商品 - 询价需求
export const updateInquirySkuCodeService = (data, loadingFn) => sourcingRequest({
  url: 'inquiry/updateInquiryEntryMainSku',
  type: 'POST',
  data,
  loadingFn,
})

// 修改商品为主码商品 - 订货需求
export const updateOrderSkuCodeService = (data, loadingFn) => sourcingRequest({
  url: 'orderGoodsEntry/updateOrderGoodsEntryMainSku',
  type: 'POST',
  data,
  loadingFn,
})
